package org.hbs.blog.code.dao.impl;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;

import org.apache.ibatis.session.SqlSessionFactory;
import org.hbs.blog.code.dao.IUserDao;
import org.hbs.blog.code.entity.User;
import org.mybatis.spring.support.SqlSessionDaoSupport;
import org.springframework.stereotype.Repository;

@Repository("userDao")
public class UserDao extends SqlSessionDaoSupport implements IUserDao {

	@Resource(name="sqlSessionFactory")
	private SqlSessionFactory sqlSessionFactory;
	
	@PostConstruct
	public void initializeSqlSessionFactory(){
		super.setSqlSessionFactory(sqlSessionFactory);
	}
	
	public User insertUser(User userInfo) {
		super.getSqlSession().insert("insertUser", userInfo);
		return userInfo;
	}

	public User selectUserByParam(User userParam) {
		return super.getSqlSession().selectOne("selectUserByParam", userParam);
	}

}
